]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell/app: Be extra careful when applying GPU environment
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 24 Apr 2026 22:19:36 +0000 (00:19 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 26 Apr 2026 13:06:13 +0000 (15:06 +0200)
We get the environment from SwitcherooControl as an array of
key-value pairs. When applying it, we loop over the array in pairs,
assuming that every key has a value.

While this is the expected format, it does not hurt to be defensive
against possible bugs in the service, so explicitly check that both
key and value are non-NULL before applying them.

Spotted by papagai.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4194>

src/shell-app.c

index ed7ecfffe33e445054515979cff281a41da3ac3d..acb996c0ba58094eef26f06478e0a121e63e2c41 100644 (file)
@@ -1338,7 +1338,7 @@ apply_discrete_gpu_env (GAppLaunchContext *context,
         continue;
 
       env_s = g_variant_get_strv (env, NULL);
-      for (j = 0; env_s[j] != NULL; j = j + 2)
+      for (j = 0; env_s[j] != NULL && env_s[j+1] != NULL; j = j + 2)
         g_app_launch_context_setenv (context, env_s[j], env_s[j+1]);
       return;
     }